import {ServicePrefixEnum} from "@/enums/commonEnum";
import {RequestEnum} from "@/enums/httpEnum";
import type {AxiosRequestConfig} from "axios";
import {defHttp} from "@/utils/http/axios";

export interface OAuth2TokenVO {
  id: number
  accessToken: string
  refreshToken: string
  userId: number
  userType: number
  clientId: string
  createTime: Date
  expiresTime: Date
}

const MODULAR = '/system/oauth2-token';

export const Api = {
  GetAccessTokenPage: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/page`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  DeleteAccessToken: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/delete`,
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig
}

// 查询 token列表
export const getAccessTokenPage = (params) => {
  return defHttp.request({ ...Api.GetAccessTokenPage,params})
}

// 删除 token
export const deleteAccessToken = (accessToken) => {
  let params = {accessToken:accessToken}
  return defHttp.request({ ...Api.DeleteAccessToken,params})
}